<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta name="referrer" content="no-referrer"><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><title>03.Python基础语法 | 王扣笔记</title><meta name="author" content="王扣"><meta name="copyright" content="王扣"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="Python入门课程 基础语法 章节目录 [!WARNING|label:本章需要学习的内容]   字面量 注释 变量 数据类型 数据类型转换 标识符 运算符 字符扩展 数据输入   字面量 [!tip|style:callout|label:学习目标] 1.了解字面量的含义2.了解常见的字面量类型 3.基于Print语句完成各类字面量的输出  需要注意：python是通过空格来识别，需要强制空格">
<meta property="og:type" content="article">
<meta property="og:title" content="03.Python基础语法">
<meta property="og:url" content="http://grace.666443.xyz/posts/a5fa344e.html">
<meta property="og:site_name" content="王扣笔记">
<meta property="og:description" content="Python入门课程 基础语法 章节目录 [!WARNING|label:本章需要学习的内容]   字面量 注释 变量 数据类型 数据类型转换 标识符 运算符 字符扩展 数据输入   字面量 [!tip|style:callout|label:学习目标] 1.了解字面量的含义2.了解常见的字面量类型 3.基于Print语句完成各类字面量的输出  需要注意：python是通过空格来识别，需要强制空格">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://p.ananas.chaoxing.com/star3/origin/ce756cc85425d56cab1a5e7cf7934af0.png">
<meta property="article:published_time" content="2022-12-08T11:35:41.000Z">
<meta property="article:modified_time" content="2022-12-08T12:09:10.049Z">
<meta property="article:author" content="王扣">
<meta property="article:tag" content="笔记 开发">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://p.ananas.chaoxing.com/star3/origin/ce756cc85425d56cab1a5e7cf7934af0.png"><link rel="shortcut icon" href="/img/favicon.png"><link rel="canonical" href="http://grace.666443.xyz/posts/a5fa344e"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: {"path":"/search.xml","preload":true,"languages":{"hits_empty":"找不到您查询的内容：${query}"}},
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: {"chs_to_cht":"你已切换为繁体","cht_to_chs":"你已切换为简体","day_to_night":"你已切换为深色模式","night_to_day":"你已切换为浅色模式","bgLight":"#49b1f5","bgDark":"#1f1f1f","position":"bottom-left"},
  source: {
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isAnchor: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: '03.Python基础语法',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2022-12-08 20:09:10'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><meta name="generator" content="Hexo 5.4.2"></head><body><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="https://i.loli.net/2021/02/24/5O1day2nriDzjSu.png" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">22</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">1</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">4</div></a></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fa fa-heartbeat"></i><span> 清单</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/music/"><i class="fa-fw fas fa-music"></i><span> 音乐</span></a></li><li><a class="site-page child" href="/photos/"><i class="fa-fw fas fa-images"></i><span> 照片</span></a></li><li><a class="site-page child" href="/movies/"><i class="fa-fw fas fa-video"></i><span> 电影</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('https://p.ananas.chaoxing.com/star3/origin/ce756cc85425d56cab1a5e7cf7934af0.png')"><nav id="nav"><span id="blog_name"><a id="site-name" href="/">王扣笔记</a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fa fa-heartbeat"></i><span> 清单</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/music/"><i class="fa-fw fas fa-music"></i><span> 音乐</span></a></li><li><a class="site-page child" href="/photos/"><i class="fa-fw fas fa-images"></i><span> 照片</span></a></li><li><a class="site-page child" href="/movies/"><i class="fa-fw fas fa-video"></i><span> 电影</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">03.Python基础语法</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2022-12-08T11:35:41.000Z" title="发表于 2022-12-08 19:35:41">2022-12-08</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2022-12-08T12:09:10.049Z" title="更新于 2022-12-08 20:09:10">2022-12-08</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/python%E5%9F%BA%E7%A1%80/">python基础</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="03.Python基础语法"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"><i class="fa-solid fa-spinner fa-spin"></i></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h1 id="Python入门课程-基础语法"><a href="#Python入门课程-基础语法" class="headerlink" title="Python入门课程 基础语法"></a>Python入门课程 基础语法</h1><hr>
<h2 id="章节目录"><a href="#章节目录" class="headerlink" title="章节目录"></a><strong>章节目录</strong></h2><blockquote>
<p>[!WARNING|label:本章需要学习的内容]</p>
</blockquote>
<ul>
<li>字面量</li>
<li>注释</li>
<li>变量</li>
<li>数据类型</li>
<li>数据类型转换</li>
<li>标识符</li>
<li>运算符</li>
<li>字符扩展</li>
<li>数据输入</li>
</ul>
<hr>
<h2 id="字面量"><a href="#字面量" class="headerlink" title="字面量"></a><em>字面量</em></h2><blockquote>
<p>[!tip|style:callout|label:学习目标] 1.了解字面量的含义<br/>2.了解常见的字面量类型 <br/>3.基于Print语句完成各类字面量的输出</p>
</blockquote>
<p><em>需要注意：python是通过空格来识别，需要强制空格的数量</em> </p>
<p> <strong>1. 掌握字面量的含义</strong></p>
<p>代码中，被写在代码中的固定的值，称之为字面量</p>
<p><strong>2. 常见的字面量类型</strong></p>
<p>我们目前了解：整数、浮点数、字符串这三类即可</p>
<p><strong>3. 如何基于print语句完成各类字面量的输出</strong> </p>
<pre><code>print(字面量)，如： 
print(10)，输出整数10 
print(13.14)，输出浮点数13.14 
print(&quot;黑马程序员&quot;)，输出字符串：黑马程序员
</code></pre>
 <img src="https://img.php.cn/upload/image/503/875/406/1666235154778802.png" title="1666235154778802.png" alt="图片 1.png"/>

<hr>
<h2 id="注释"><a href="#注释" class="headerlink" title="注释"></a><em>注释</em></h2><blockquote>
<p>[!tip|style:callout|label:学习目标] 1.了解注释的作用<br> 2.能够使用单行注释和多行注释</p>
</blockquote>
<p><strong>注释：在程序代码中对程序代码进行解释说明的文字。</strong></p>
<blockquote>
<p>作用：注释不是程序，不能被执行，只是对程序代码进行解释说明，<br>   让别人可以看懂程序代码的作用，能够大大增强程序的可读性。</p>
</blockquote>
<p><strong><pred>注释的分类</pred></strong></p>
<ul>
<li>单行注释：以 #开头，#右边 的所有文字当作说明，而不是真正要执行的程序，起辅助说明作用<img src="https://img.php.cn/upload/image/484/656/178/1666224662897982.png" with="250px" height="40px" /></li>
<li>多行注释： 以 一对三个双引号 引起来 (   <code>  &quot;&quot;&quot;注释内容&quot;&quot;&quot;</code>        )来解释说明一段代码的作用使用方法<img src='https://img.php.cn/upload/image/971/268/725/1666224538763151.png' with="217px" height="185px"></li>
</ul>
<blockquote>
<p><strong><pred>注释实战</pred></strong></p>
</blockquote>
<div style="width:100%;heigth:270px;display:block">
    <div style="display:block;float:left;width:45%;height:270px;line-height:40px;">
        按照如图所示，对代码添加 <br/>
            ●  单行注释以及<br/>
            ●  多行注释<br/>
        添加完成注释后，执行程序<br/>
        验证注释是否对程序产生影响<br/>
    </div>
    <div style="display:block;float:left;height:270px;width:300px">
        <img src="https://img.php.cn/upload/image/913/170/716/1666224923171066.png" style="max-height:270px">
    </div> 
</div>
<div style="clear:both"></div>  

<hr>
<img src="https://img.php.cn/upload/image/792/888/203/1666234963384460.png" style="max-height:700px"> 

<hr>
<h2 id="变量"><a href="#变量" class="headerlink" title="变量"></a><em>变量</em></h2><p><img src="https://img.php.cn/upload/image/942/242/315/1666235424905242.png" alt="学习目标"><br><img src="https://img.php.cn/upload/image/207/623/301/1666235466602403.png" alt="什么是变量"><br><img src="https://img.php.cn/upload/image/669/918/685/1666235575414041.png" alt="变量总结"></p>
<hr>
<h2 id="数据类型"><a href="#数据类型" class="headerlink" title="数据类型"></a><em>数据类型</em></h2><p><img src="https://img.php.cn/upload/image/546/182/968/1666235650729196.png" alt="学习目标"><br><img src="https://img.php.cn/upload/image/617/679/482/1666235703531568.png" alt="数据类型"><br><img src="https://img.php.cn/upload/image/710/323/296/1666235761219340.png" alt="type语句"><br><img src="https://img.php.cn/upload/image/277/982/179/1666235916168823.png"><br><img src="https://img.php.cn/upload/image/468/175/166/1666235949343529.png"><br><img src="https://img.php.cn/upload/image/435/323/284/1666235965811331.png"><br><img src="https://img.php.cn/upload/image/758/138/914/1666235980813346.png"><br><img src="https://img.php.cn/upload/image/329/664/418/1666235993469003.png"></p>
<hr>
<h2 id="数据类型转换"><a href="#数据类型转换" class="headerlink" title="数据类型转换"></a><em>数据类型转换</em></h2><p><img src="https://img.php.cn/upload/image/946/888/947/1666236106441139.png" alt="学习目标"><br><img src="https://img.php.cn/upload/image/274/651/504/1666236118774703.png" alt="为什么要数据类型转换"><br><img src="https://img.php.cn/upload/image/247/667/731/1666236212134247.png" alt="常见的转换语句"><br><img src="https://img.php.cn/upload/image/832/953/197/1666236282565148.png" alt="注意事项"><br><img src="https://img.php.cn/upload/image/278/144/892/1666236293833829.png" alt="总结"></p>
<hr>
<h2 id="标识符"><a href="#标识符" class="headerlink" title="标识符"></a><em>标识符</em></h2><p><img src="https://img.php.cn/upload/image/153/377/824/1666236627123336.png" alt="学习目标"><br><img src="https://img.php.cn/upload/image/302/435/549/1666236654706765.png"><br><img src="https://img.php.cn/upload/image/599/852/226/1666236675720519.png"><br><img src="https://img.php.cn/upload/image/780/312/201/1666236710557662.png"><br><img src="https://img.php.cn/upload/image/937/499/945/1666236730952586.png"><br><img src="https://img.php.cn/upload/image/745/556/548/1666236757738985.png"><br><img src="https://img.php.cn/upload/image/919/690/654/1666236762157018.png"><br><img src="https://img.php.cn/upload/image/954/151/719/1666236768379462.png"><br><img src="https://img.php.cn/upload/image/390/479/543/1666236913736055.png"><br><img src="https://img.php.cn/upload/image/672/675/479/1666236917727439.png"><br><img src="https://img.php.cn/upload/image/799/785/208/1666236922527310.png"></p>
<hr>
<h2 id="运算符"><a href="#运算符" class="headerlink" title="运算符"></a><em>运算符</em></h2><p><img src="https://img.php.cn/upload/image/116/298/143/1666237167468604.png"><br><img src="https://img.php.cn/upload/image/261/365/867/1666237170858534.png"><br><img src="https://img.php.cn/upload/image/777/880/189/1666237173222965.png"><br><img src="https://img.php.cn/upload/image/689/913/123/1666237176310759.png"><br><img src="https://img.php.cn/upload/image/484/314/504/1666237179386611.png"> </p>
<hr>
<h2 id="字符扩展"><a href="#字符扩展" class="headerlink" title="字符扩展"></a><em>字符扩展</em></h2><blockquote>
<p>字符串扩展需要学习以下章节内容</p>
</blockquote>
<ul>
<li>①字符串的三种定义方式</li>
<li>②字符串拼接</li>
<li>③字符串格式化</li>
<li>④格式化的精度控制</li>
<li>⑤字符串格式化方式2</li>
<li>⑥对表达式进行格式化</li>
</ul>
<blockquote>
<p>[!tip|style:callout|label:①字符串的三种定义方式]</p>
</blockquote>
<p><img src="https://img-blog.csdnimg.cn/e5ae32a4272d4b3da93100a3cac25252.png"><br><img src="https://img-blog.csdnimg.cn/9e8bb6c48be145febcadc26ab8225de6.png"><br><img src="https://img-blog.csdnimg.cn/49cd82d9920340e1b774a855824a611f.png"></p>
<blockquote>
<p>[!tip|style:callout|label:②字符串拼接] </p>
</blockquote>
<p><img src="https://img-blog.csdnimg.cn/d5306aa8fc864398b559269d02f40193.png"><br><img src="https://img-blog.csdnimg.cn/0e860f1233fe4183ae9a00580214b6cc.png"><br><img src="https://img-blog.csdnimg.cn/15f507588b8645dc909fb1777d72098a.png"><br><img src="https://img-blog.csdnimg.cn/72170ea02fee41698f0fccba61c1125a.png"><br><img src="https://img-blog.csdnimg.cn/760ecc68c5b44b94903ab709599344eb.png"></p>
<blockquote>
<p>[!tip|style:callout|label:③字符串格式化] </p>
</blockquote>
<p><strong>学习目标：掌握通过占位的形式拼接字符串（字符串格式化）</strong></p>
<p><img src="https://img-blog.csdnimg.cn/0db95fbe8fb744d4895fdfd5fe819907.png"><br><img src="https://img-blog.csdnimg.cn/9c9649b32a7844fdbf032ba50179a566.png"><br><img src="https://img-blog.csdnimg.cn/b650eb0961e84ce8af1d0ce9da0b8185.png"><br><img src="https://img-blog.csdnimg.cn/b183d9babf204c4199fd8600005a3e98.png"><br><img src="https://img-blog.csdnimg.cn/fad7a6818fd3455999fcf6072ff82fcf.png"><br><img src="https://img-blog.csdnimg.cn/d7a2208f99d24afcbe1e0ce3073fc687.png"></p>
<blockquote>
<p>[!tip|style:callout|label:④格式化的精度控制] </p>
</blockquote>
<p><img src="https://img-blog.csdnimg.cn/ed0c1ffad310424096f4419a40c17c21.png" alt="Snipaste_2022-10-21_07-54-48.png"><br><img src="https://img-blog.csdnimg.cn/e956fc47bc2b409a89903bfaf20d34a9.png" alt="2.png"><br><img src="https://img-blog.csdnimg.cn/b85c8cbbfdfd42d0b1cf0673236564cf.png" alt="3.png"><br><img src="https://img-blog.csdnimg.cn/7eaaa99afb424dbaafdaf3b5f0cb3334.png" alt="4.png"><br><img src="https://img-blog.csdnimg.cn/a9b7c60c754a4ddbaafe358493e8576e.png" alt="5.png"></p>
<blockquote>
<p>[!tip|style:callout|label:⑤字符串格式化方式2] </p>
</blockquote>
<p><img src="https://img-blog.csdnimg.cn/23bb10e2fccb4c648885d88f4b84c86d.png" alt="1.png"><br><img src="https://img-blog.csdnimg.cn/e6905d7d55a6446091ffd8820ca68ef0.png" alt="2.png"><br><img src="https://img-blog.csdnimg.cn/4c8c0aec684b4ec88c02b25d89398287.png" alt="3.png"></p>
<blockquote>
<p>[!tip|style:callout|label:⑥对表达式进行格式化] </p>
</blockquote>
<p><img src="https://img-blog.csdnimg.cn/95c5b07e2ab64620b27980425267911f.png" alt="1.png"><br><img src="https://img-blog.csdnimg.cn/7f4d057dfd144e78aec835ead8a60369.png" alt="2.png"><br><img src="https://img-blog.csdnimg.cn/4bdda37147ee40b0a6ef890213ff0bf1.png" alt="3.png"><br><img src="https://img-blog.csdnimg.cn/3dcca7061d6f467d9967e12ff188dbac.png" alt="4.png"></p>
<hr>
<h2 id="数据输入"><a href="#数据输入" class="headerlink" title="数据输入"></a><em>数据输入</em></h2><p><img src="https://img-blog.csdnimg.cn/ae3b80f5c4944053ae8583caf85e9e63.png" alt="1.png"><br><img src="https://img-blog.csdnimg.cn/e52332439a214d7cb4944cfac2c27be3.png" alt="2.png"><br><img src="https://img-blog.csdnimg.cn/0e9f54903c83494294294aaab9494805.png" alt="3.png"><br><img src="https://img-blog.csdnimg.cn/0c93886ed2cb499bb708d603efbd30b5.png" alt="4.png"><br><img src="https://img-blog.csdnimg.cn/194b29a297304e1487466c03f0c20dcc.png" alt="5.png"></p>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="http://grace.666443.xyz">王扣</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="http://grace.666443.xyz/posts/a5fa344e.html">http://grace.666443.xyz/posts/a5fa344e.html</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="http://grace.666443.xyz" target="_blank">王扣笔记</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"></div><div class="post_share"><div class="social-share" data-image="https://p.ananas.chaoxing.com/star3/origin/ce756cc85425d56cab1a5e7cf7934af0.png" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/posts/9b6113bf.html"><img class="prev-cover" src="https://p.ananas.chaoxing.com/star3/origin/f477c264e6f1e4c9138450a3a0359907.png" onerror="onerror=null;src='/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">04.Python判断语句</div></div></a></div><div class="next-post pull-right"><a href="/posts/f429f6b8.html"><img class="next-cover" src="https://p.ananas.chaoxing.com/star3/origin/8e59e20a807e27665683c139ee344255.png" onerror="onerror=null;src='/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">02-pycharm安装和激活</div></div></a></div></nav></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src="https://i.loli.net/2021/02/24/5O1day2nriDzjSu.png" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">王扣</div><div class="author-info__description">常用开发中的笔记记录</div></div><div class="card-info-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">22</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">1</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">4</div></a></div><a id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/xxxxxx"><i class="fab fa-github"></i><span>Follow Me</span></a></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>公告</span></div><div class="announcement_content">This is my Blog 技术笔记</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#Python%E5%85%A5%E9%97%A8%E8%AF%BE%E7%A8%8B-%E5%9F%BA%E7%A1%80%E8%AF%AD%E6%B3%95"><span class="toc-number">1.</span> <span class="toc-text">Python入门课程 基础语法</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%AB%A0%E8%8A%82%E7%9B%AE%E5%BD%95"><span class="toc-number">1.1.</span> <span class="toc-text">章节目录</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%AD%97%E9%9D%A2%E9%87%8F"><span class="toc-number">1.2.</span> <span class="toc-text">字面量</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%B3%A8%E9%87%8A"><span class="toc-number">1.3.</span> <span class="toc-text">注释</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%8F%98%E9%87%8F"><span class="toc-number">1.4.</span> <span class="toc-text">变量</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B"><span class="toc-number">1.5.</span> <span class="toc-text">数据类型</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B%E8%BD%AC%E6%8D%A2"><span class="toc-number">1.6.</span> <span class="toc-text">数据类型转换</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%A0%87%E8%AF%86%E7%AC%A6"><span class="toc-number">1.7.</span> <span class="toc-text">标识符</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E8%BF%90%E7%AE%97%E7%AC%A6"><span class="toc-number">1.8.</span> <span class="toc-text">运算符</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%AD%97%E7%AC%A6%E6%89%A9%E5%B1%95"><span class="toc-number">1.9.</span> <span class="toc-text">字符扩展</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%95%B0%E6%8D%AE%E8%BE%93%E5%85%A5"><span class="toc-number">1.10.</span> <span class="toc-text">数据输入</span></a></li></ol></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/posts/ae1a0acd.html" title="18.Python爬虫-requests模块"><img src="https://p.ananas.chaoxing.com/star3/origin/b230c5f9060b1f422a86e332d8e37926.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="18.Python爬虫-requests模块"/></a><div class="content"><a class="title" href="/posts/ae1a0acd.html" title="18.Python爬虫-requests模块">18.Python爬虫-requests模块</a><time datetime="2022-12-08T12:53:30.000Z" title="发表于 2022-12-08 20:53:30">2022-12-08</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/posts/ed7a56b2.html" title="17.Python爬虫-数据解析与提取"><img src="https://p.ananas.chaoxing.com/star3/origin/8f2179d04bfe0e48cc706ae112c97952.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="17.Python爬虫-数据解析与提取"/></a><div class="content"><a class="title" href="/posts/ed7a56b2.html" title="17.Python爬虫-数据解析与提取">17.Python爬虫-数据解析与提取</a><time datetime="2022-12-08T12:52:55.000Z" title="发表于 2022-12-08 20:52:55">2022-12-08</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/posts/5038ed.html" title="16.Python爬虫-基础"><img src="https://p.ananas.chaoxing.com/star3/origin/2054c03c91d338203c730610ead1b303.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="16.Python爬虫-基础"/></a><div class="content"><a class="title" href="/posts/5038ed.html" title="16.Python爬虫-基础">16.Python爬虫-基础</a><time datetime="2022-12-08T12:52:11.000Z" title="发表于 2022-12-08 20:52:11">2022-12-08</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/posts/2b5a0751.html" title="15.Python之Mysql数据库相关"><img src="https://p.ananas.chaoxing.com/star3/origin/2a1821704670b5cf8c2289255e183d62.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="15.Python之Mysql数据库相关"/></a><div class="content"><a class="title" href="/posts/2b5a0751.html" title="15.Python之Mysql数据库相关">15.Python之Mysql数据库相关</a><time datetime="2022-12-08T12:17:02.000Z" title="发表于 2022-12-08 20:17:02">2022-12-08</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/posts/6ebaa02b.html" title="14.Python面向对象"><img src="https://p.ananas.chaoxing.com/star3/origin/d24d9bfcd4ce3f910d6b5cdc78676d75.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="14.Python面向对象"/></a><div class="content"><a class="title" href="/posts/6ebaa02b.html" title="14.Python面向对象">14.Python面向对象</a><time datetime="2022-12-08T12:10:47.000Z" title="发表于 2022-12-08 20:10:47">2022-12-08</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2022 By 王扣</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div id="local-search"><div class="search-dialog"><nav class="search-nav"><span class="search-dialog-title">搜索</span><span id="loading-status"></span><button class="search-close-button"><i class="fas fa-times"></i></button></nav><div class="is-center" id="loading-database"><i class="fas fa-spinner fa-pulse"></i><span>  数据库加载中</span></div><div class="search-wrap"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div><hr/><div id="local-search-results"></div></div></div><div id="search-mask"></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.umd.min.js"></script><script src="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.js"></script><script src="/js/search/local-search.js"></script><div class="js-pjax"><script>(() => {
  const $mermaidWrap = document.querySelectorAll('#article-container .mermaid-wrap')
  if ($mermaidWrap.length) {
    window.runMermaid = () => {
      window.loadMermaid = true
      const theme = document.documentElement.getAttribute('data-theme') === 'dark' ? 'dark' : 'default'

      Array.from($mermaidWrap).forEach((item, index) => {
        const mermaidSrc = item.firstElementChild
        const mermaidThemeConfig = '%%{init:{ \'theme\':\'' + theme + '\'}}%%\n'
        const mermaidID = 'mermaid-' + index
        const mermaidDefinition = mermaidThemeConfig + mermaidSrc.textContent
        mermaid.mermaidAPI.render(mermaidID, mermaidDefinition, (svgCode) => {
          mermaidSrc.insertAdjacentHTML('afterend', svgCode)
        })
      })
    }

    const loadMermaid = () => {
      window.loadMermaid ? runMermaid() : getScript('https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js').then(runMermaid)
    }

    window.pjax ? loadMermaid() : document.addEventListener('DOMContentLoaded', loadMermaid)
  }
})()</script></div><script defer="defer" id="ribbon" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/dist/canvas-ribbon.min.js" size="150" alpha="0.6" zIndex="-1" mobile="false" data-click="false"></script><div class="fb-customerchat" id="fb-customer-chat" attribution="biz_inbox"></div><script>document.getElementById('fb-root') ? '' : document.body.insertAdjacentHTML('afterend', '<div id="fb-root"></div>')

window.fbAsyncInit = function() {
  FB.init({
    xfbml: true,
    version: 'v15.0'
  });
};

(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = 'https://connect.facebook.net/zh_CN/sdk/xfbml.customerchat.js';
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));

if (false) {
  var chatBtnFn = () => {
    var chatBtn = document.getElementById("chat_btn")
    chatBtn.addEventListener("click", function(){
      FB.CustomerChat.show();
    });
  }
  chatBtnFn()
} else {
  if (false) {
    function chatBtnHide () {
      FB.CustomerChat.hide()
    }
    function chatBtnShow () {
      FB.CustomerChat.show(false)
    }
  }
}</script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div></body></html>